// pages/index/index.js
const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    markers: [{
      iconPath: "../../image/location@2x(2).png",
      id: 0,
      latitude: 23.099994,
      longitude: 113.324520,
      width: 18,
      height: 24
    }],
    houseDetail: {
      latitude: 23.099994,
      longitude: 113.324520,
    }
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    wx.getSystemInfo({//获取滑块的高宽
      success: function (res) {
        that.setData({
          winWidth: res.windowWidth,
          winHeight: res.windowHeight,
          imageUrl: app.globalData.imageUrl
        });
      }
    });
    getComplaninfo(this)
  },
  calling: function (e) {
    wx.makePhoneCall({
      phoneNumber: '' + e.target.id,
    })
  },
  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
  , toLocal:function(e){
    wx.openLocation({
      latitude: parseFloat(e.target.dataset.lat) ,
      longitude: parseFloat(e.target.dataset.lon),
    })
  }
})

function getComplaninfo(that) {
  wx.request({
    url: app.globalData.allUrl + "/user/get_company",
    data: {
    },
    method: 'GET',
    success: function (res) {
      console.log(res.data)
      that.data.markers[0].latitude = res.data[0].gps_w
      that.data.markers[0].longitude = res.data[0].gps_j
      that.setData({
        houseDetail:res.data[0],
        markers: that.data.markers
      })
    }
  })
}